<?php
if (!defined('__COLA_DIR__')) exit;
/**
 * Widget抽象组件
 *
 * @author edikud
 * @package Widget
 * @copyright Copyright (c) 2019 Cola (http://www.mcooo.com)
 * @license GNU General Public License 2.0
 */

abstract class Widget extends Cola
{
    /**
     * 全局选项
     *
     * @access protected
     * @var Widget_Options
     */
    public $options;

    /**
     * 用户对象
     *
     * @access protected
     * @var Widget_User
     */
    public $user;

    /**
     * 安全模块
     *
     * @var Widget_Security
     */
    public $security;	
	
    /**
     * 结果对象
     *
     * @access protected
     * @var Widget_User
     */
    public $result;
	
    /**
     * 数据库对象
     *
     * @access protected
     * @var Db
     */
    public $db;
	
    /**
     * 构造函数,初始化组件
     *
     * @access public
     * @param mixed $request request对象
     * @param mixed $response response对象
     * @param mixed $params 参数列表
     */
    public function __construct($request, $response, $params = NULL)
    {
        parent::__construct($request, $response, $params);

        /** 初始化数据库 */
        $this->db = Db::instance();

        /** 初始化常用组件 */
        $this->options = $this->widget('Widget_Options');
        $this->user = $this->widget('Widget_User');
        $this->security = $this->widget('Widget_Security');
        $this->result = $this->widget('Widget_Result');
    }
}
